#include "pid_menu_handler.h"

float kp = 0;
float ki = 0;
float kd = 0;

extern menu_t pid_menu[5];

void pid_menu_init(void)
{
  snprintf(pid_menu[0].disp_str, 16, "KP: %.2f", kp);
  snprintf(pid_menu[1].disp_str, 16, "KI: %.2f", ki);
  snprintf(pid_menu[2].disp_str, 16, "KD: %.2f", kd);
}

void pid_val_add(uint8_t select_item)
{
  switch(select_item)
  {
    case 0:
      kp += 0.1;
      break;
    case 1:
      ki += 0.1;
      break;
    case 2:
      kd += 0.1;
      break;
  }
  pid_menu_init();
  menu_refresh();
}

void pid_val_remove(uint8_t select_item)
{
  switch(select_item)
  {
    case 0:
      kp -= 0.1;
      break;
    case 1:
      ki -= 0.1;
      break;
    case 2:
      kd -= 0.1;
      break;
  }
  pid_menu_init();
  menu_refresh();
}

void pid_save(uint8_t select_item)
{
  menu_dialog("OK",NULL);
}